<?
require ( "../includes/config.php" );
require ( "../includes/CGI.php" );
require ( "../includes/SQL.php" );

$cgi = new CGI ();
$sql = new SQL ( $DBusername, $DBpassword, $server, $database );

if ( ! $sql->isConnected () )
{
  die ( $DatabaseError );
}

require ( "includes/Auth.php" );
$auth = new Auth ( $cgi, $sql, $admin_table );
$auth->checkAuth ( "index.php" );
  require ( "resizer.php" );
  
  $rows2 = $sql->execute ( "SELECT * FROM " . $configure_table . " LIMIT 1",
    SQL_RETURN_ASSOC );
  $row2 = $rows2 [ 0 ];
$imagepath = $cgi->htmlEncode ( $row2 [ "imagepath" ] );
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"> 
<head> 
<title>Deletar Imagem</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<link href="style.css" rel="stylesheet" type="text/css" /> 
<style type="text/css">
<!--
.style1 {color: #FF0000}
-->
</style>
</head> 
<body> 
<table border="0" cellpadding="1" cellspacing="0" width="100%"> 
<tbody> 
<tr> 
<td bgcolor="#333333"> <?PHP include "header.php"; ?>
<table bgcolor="#ffffff" border="0" cellpadding="0" cellspacing="0" width="100%"> 
<tbody> 
<tr> 
<td colspan="4"> 
<table width="100%" cellpadding="0" cellspacing="0"> 
<tr> 
<td align="left" valign="top" class="leftbg"> <?PHP include "leftmenu.php"; ?></td> 
<td width="100%" valign="top"> 
<h2 align="left"><img src="images/spacer.gif" height="10" width="15" />Deletar Imagem </h2> 
<table width="95%" cellpadding="0" cellspacing="1"> 
<tr> 
<td> 

<?

$rows = $sql->execute ( "UPDATE " .$property_table. " SET " . $cgi->getValue ("imageno"). " = '' 
WHERE id = ".$sql->quote ( $cgi->getValue ( "propid" ))); 
	
	if($_POST['propertyphoto'] != 'nopropertyimage.jpg'){
$filename = $imagepath."/".$_POST['propertyphoto'];
$return = @unlink($filename);
}else{
echo "Default no image cannot be deleted.";
}
?> 
<p align="center" class="style1">Imagem deletada com sucesso!</p>
<br />
<form method="post" action="property_edit.php">
<input name="op" type="hidden" value="editestablishment" />
<input name="id" type="hidden" value="<?=$_POST['propid']; ?>" />
<p align="center">
<input value="Ver detalhes" type="submit" class="textinput" />
</p>
</form></td> 
</tr> 
</table><br /><br /></td>
</tr> 
</table> </td> 
</tr> 
</tbody> 
</table> </td> 
</tr> 
</tbody> 
</table> <?PHP include "footer.php"; ?>
</body>
</html>
